#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>

/** Declare the original malloc for use in the wrapper.*/
void *__real_malloc (size_t);

/** Wrap malloc and have it exit the program if it is unable to allocate any memory. */
void * __wrap_malloc(size_t size)
{
    void *lptr = __real_malloc(size);
    if(lptr == NULL) {
      perror("malloc failed\n"); exit(2);
    }
    return lptr;
}
